using Godot;
using System;

public partial class ActionAttack : BTLeaf
{
	public Player _player;
	private Movement _movement;
	private AnimationPlay _animationPlay;
	private Map _map;
	public override void run()
    {
		base.run();
		Characters parentOfType = FindParentOfType<Characters>(this);
		_character = parentOfType;

		wait(_character.CharacterData.attacksec);
		if(_character.GetNode<SkillManager>("SkillManager").ChooseSkill())
		{
			Characters targetCharacter = GetTree().CurrentScene.GetNode<Characters>("%"+(_character.CharacterData as EnemyData).target);
			_stateMachine.current_state = (int)Characters.State.SKILL;
			_character.GetNode<SkillManager>("SkillManager").CurrentSkill.SkillTocharacter(_character,targetCharacter);
			EmitSignal(SignalName.completed,succeed());
		}
		else
		{EmitSignal(SignalName.completed,faile());}
    }
	public override double Utility()
    {
		Characters parentOfType = FindParentOfType<Characters>(this);
		_character = parentOfType; 
		var Game = GetNode<Game>("/root/Game");
		_player = Game.get_player();
        double value = 0.0;
		if(_character.GetNode<SkillManager>("SkillManager").ChooseSkill())
		{
			value = 0.9;
			GD.Print("攻击优先级" + value);
		}
		return value;
    }
}
